<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title>
  <script type="text/javascript" src="../vue.js"></script>
  <style>
    .public {
      width: 100px;
      height: 100px;
    }

    .Active {
      background: red;
    }

    .noActive {
      background: blue;
    }

    .black {
      background-color: black;
    }

    .color {
      color: yellowgreen;
    }

    .green {
      background-color: green;
    }

    .fontSize {
      font-size: 20px;
    }

    .bold {
      font-weight: bold;
    }

    .red {
      background-color: red;
    }
  </style>
</head>

<!-- 
      1.动态class:值是一个字符串
        用法:类名一般只有一个,并且不确定是哪一个
     -->


<!-- 
      2.动态class:值是一个对象,对象的key都是需要的class名称,值是布尔值,通过布尔值来控制当前类是否使用
        用法:类固定,但是不确定用不用
     -->

<!-- 
      3.动态class:值是一个数组
        用法:类型个数不固定,可以操作数组,对类名进行增删改
     -->


<body>
  <div id="app">
    <div class="public">zero</div>
    <div class="public" :class="isActive?'Active':'noActive'">one</div>
    <div class="public" :class="noActive?'Active':'noActive'">two</div>
    <div class="public" :class="threeColor">three</div>
    <div class="public" :class="{color:isColor,green:isGreen,fontSize:isFontSize}">four</div>
    <div class="public" :class="arr">five</div>
  </div>
</body>
<script type="text/javascript">
  Vue.config.productionTip = false;
  const vm = new Vue({
    el: "#app",
    data() {
      return {
        isActive: true,
        noActive: false,
        threeColor: {
          red: true,
        },
        isColor: true,
        isGreen: true,
        fontSize: true,
        bold: "true",
        arr: ["fontSize","bold","red"]
      }
    }
  })
</script>

</html>